import express, { Application } from 'express';
import cors from 'cors'

import { resolve } from '../utils/common';
/**
 * 加载中间件
 * @param app 
 */
export const loadMidd = (app: Application) => {
    // 跨域处理
    app.use(cors())

    // 静态资源文件
    app.use(express.static(resolve('../public')));

    // 头像静态资源
    app.use(express.static(resolve('../public/avatar')));
    
    // 解析body的application/json
    app.use(express.json());

    // 解析form表单 application/x-www-form-urlencoded
    app.use(express.urlencoded({ extended: true }));
}